import i18n from 'i18next'
import { initReactI18next } from 'react-i18next'

// 简易的资源，可按需拆分到单独 json 文件
const resources = {
  zh: {
    translation: {
      greeting: '你好，世界！',
      chat_title: '星火认知大模型对话',
      send: '发送',
      clear: '清空对话',
      stop: '停止朗读',
      choose_action: '选择动作',
      change_language: '切换语言',
      lang_zh: '中文',
      lang_en: 'English',
      loading: '加载中',
      browser_tts_not_supported: '您的浏览器不支持语音合成功能',
      tts_unavailable: '语音合成功能不可用',
      speak_failed: '朗读失败: {{error}}',
      auto_speech_enabled: '已开启自动朗读',
      auto_speech_disabled: '已关闭自动朗读',
      test_speech_title: '测试朗读功能',
      auto_speech_on_title: '开启自动朗读',
      auto_speech_off_title: '关闭自动朗读',
      start_chat: '开始与AI对话吧！',
      input_placeholder: '输入您的问题... (按Enter发送，Shift+Enter换行)',
      connecting: '连接中',
      replying: '回复中',
      jump_to_exhibition: '进入3D展览馆',
      no_video2: '暂无视频二，敬请期待',
      more: '更多',
      switch_to_en: '切换到 English',
      switch_to_zh: 'Switch to 中文',
      video1: '视频一',
      video2: '视频二',
      speech_placeholder: '语音识别结果会显示在这里...',
      // Danmaku
      send_barrage: '发送弹幕',
      enable_barrage: '启用弹幕:',
      barrage_speed: '弹幕速度:',
      barrage_density: '弹幕密度:',
      opacity: '透明度:',
      please_enter_barrage: '请输入弹幕内容',
      // Login / Header
      login_success: '登录成功',
      login_failed_retry: '登录失败请重新登录',
      login_request_failed: '登录请求失败，请稍后再试',
      welcome_back: '欢迎回来',
      please_login: '请登录您的账户',
      username: '用户名',
      username_required: '用户名不能为空',
      input_username: '请输入用户名',
      password: '密码',
      password_required: '密码不能为空',
      password_min_length: '密码长度至少为 5 个字符',
      input_password: '请输入密码',
      login: '登录',
      logout: '退出登录',
      welcome: '欢迎，',
      // Exhibition
      back_home: '返回首页',
      // Theme
      night_mode: '夜间模式',
      day_mode: '白天模式',
      switch_to_day: '切换到白天',
      switch_to_night: '切换到夜间',
      switch_to_day_mode: '切换到白天模式',
      switch_to_night_mode: '切换到夜间模式',
      // ChatBot API errors
      ai_speech_autosend_error: '语音识别自动发送失败：未配置星火 API 凭据',
      credentials_missing: '缺少星火 API 凭据',
      please_enter_message: '请输入消息内容',
      send_failed_no_credentials: '发送消息失败：未配置星火 API 凭据',
      dialog_failed: '对话失败: {{message}}',
      connect_failed: '连接失败，请检查网络或API配置',
      send_failed_retry: '发送消息失败，请重试',
      voice_test_text: '这是语音合成测试，如果您能听到这段话，说明朗读功能正常工作。',
      // Scene3D
      please_choose_action: '请选择动作',
      // ChatModal
      no_messages: '暂无消息'
    }
  },
  en: {
    translation: {
      greeting: 'Hello, world!',
      chat_title: 'Spark Chat',
      send: 'Send',
      clear: 'Clear',
      stop: 'Stop Speaking',
      choose_action: 'Choose Action',
      change_language: 'Language',
      lang_zh: 'Chinese',
      lang_en: 'English',
      loading: 'Loading',
      browser_tts_not_supported: 'Your browser does not support Speech Synthesis',
      tts_unavailable: 'Speech Synthesis unavailable',
      speak_failed: 'Speak failed: {{error}}',
      auto_speech_enabled: 'Auto speech enabled',
      auto_speech_disabled: 'Auto speech disabled',
      test_speech_title: 'Test Speech',
      auto_speech_on_title: 'Enable Auto Speech',
      auto_speech_off_title: 'Disable Auto Speech',
      start_chat: 'Start chatting with AI!',
      input_placeholder: 'Type your question... (Enter to send, Shift+Enter for newline)',
      connecting: 'Connecting',
      replying: 'Replying',
      jump_to_exhibition: 'Enter 3D Exhibition',
      no_video2: 'No video 2 yet, stay tuned',
      more: 'More',
      switch_to_en: 'Switch to English',
      switch_to_zh: '切换到 中文',
      video1: 'Video 1',
      video2: 'Video 2',
      speech_placeholder: 'Speech recognition result will appear here...',
      // Danmaku
      send_barrage: 'Send Danmaku',
      enable_barrage: 'Enable Danmaku:',
      barrage_speed: 'Speed:',
      barrage_density: 'Density:',
      opacity: 'Opacity:',
      please_enter_barrage: 'Please enter content',
      // Login / Header
      login_success: 'Login successful',
      login_failed_retry: 'Login failed, please try again',
      login_request_failed: 'Login request failed, please try later',
      welcome_back: 'Welcome back',
      please_login: 'Please log in to your account',
      username: 'Username',
      username_required: 'Username is required',
      input_username: 'Enter username',
      password: 'Password',
      password_required: 'Password is required',
      password_min_length: 'Password must be at least 5 characters',
      input_password: 'Enter password',
      login: 'Login',
      logout: 'Logout',
      welcome: 'Welcome, ',
      // Exhibition
      back_home: 'Back Home',
      // Theme
      night_mode: 'Night Mode',
      day_mode: 'Day Mode',
      switch_to_day: 'Switch to Day',
      switch_to_night: 'Switch to Night',
      switch_to_day_mode: 'Switch to Day Mode',
      switch_to_night_mode: 'Switch to Night Mode',
      // ChatBot API errors
      ai_speech_autosend_error: 'Voice auto-send failed: Spark credentials missing',
      credentials_missing: 'Spark API credentials missing',
      please_enter_message: 'Please enter a message',
      send_failed_no_credentials: 'Send failed: Spark credentials not configured',
      dialog_failed: 'Dialog failed: {{message}}',
      connect_failed: 'Connection failed, check network or API config',
      send_failed_retry: 'Send failed, please retry',
      voice_test_text: 'This is a speech synthesis test. If you can hear this, speech works.',
      // Scene3D
      please_choose_action: 'Please choose an action',
      // ChatModal
      no_messages: 'No messages yet'
    }
  }
}

i18n
  .use(initReactI18next)
  .init({
    resources,
    lng: 'zh',
    fallbackLng: 'zh',
    interpolation: { escapeValue: false }
  })

export default i18n